﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace 第四次课堂作业
{
    public partial class Form1 : Form
    {
        private DateTime dt;
        private string clockTime;
        private string nowTime;
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Shown(object sender, EventArgs e)
        {
            dt = DateTime.Now;
            nowTime = label1.Text = dt.ToString("T");
            richTextBox1.Text += "tick tock!\n";
            if (clockTime == nowTime)
                richTextBox1.Text += "ring ring ring !!!\n";
        }

        private void button1_Click(object sender, EventArgs e)
        {
            clockTime = dateTimePicker1.Value.ToString("HH:mm:ss");
            richTextBox1.Text += "set the clock of " + clockTime + " \n";
        }

        private void richTextBox1_TextChanged(object sender, EventArgs e)
        {
            richTextBox1.SelectionStart = richTextBox1.TextLength;
            richTextBox1.ScrollToCaret();
        }
    }
}
